
#ifndef _CTHREAD_MONITOR_H_
#define _CTHREAD_MONITOR_H_

#include "exception.h"

namespace CThread
{

/**
 * A monitor is a combination mutex and condition-event.  Waiting and
 * notifying condition events requires that the caller own the mutex.  Mutex
 * lock and unlock operations can be performed independently of condition
 * events.  This is more or less analogous to java.lang.Object multi-thread
 * operations
 *
 * Note that all methods are const.  Monitors implement logical constness, not
 * bit constness.  This allows const methods to call monitor methods without
 * needing to cast away constness or change to non-const signatures.
 *
 * @version $Id:$
 */
class Monitor 
{
public:

	Monitor();
	~Monitor();
	void lock();
	void unlock();
	void wait(int64_t timeout=0LL);
	void notify();
	void notifyAll();

private:
	pthread_mutex_t pthread_mutex_;
	pthread_cond_t pthread_cond_;
 };
 
};

#endif // #ifndef _CTHREAD_MONITOR_H_
